class DeviceOrientationExample extends egret.DisplayObjectContainer {
    private label: egret.TextField;

    public constructor() {
        super();
        this.label = new egret.TextField();
        this.label.y = 50;
        this.label.x = 50;
        this.addChild(this.label);
        //创建 DeviceOrientation 类
        var orientation = new egret.DeviceOrientation();
        //添加事件监听器
        orientation.addEventListener(egret.Event.CHANGE, this.onOrientation, this);
        //开始监听设备方向变化
        orientation.start();
    }

    private onOrientation(e: egret.OrientationEvent) {
        this.label.text =
            "方向: nalpha:" + e.alpha
            + ",nbeta:" + e.beta
            + ",ngamma:" + e.gamma;
    }
}
